

using System.Linq;
using Abp.Authorization;
using Abp.Configuration.Startup;
using Abp.Localization;
using Abp.MultiTenancy;
using JYJ.AiYard.Authorization;

namespace JYJ.AiYard.StationManagement.TbXiaoJuParams.Authorization
{
    /// <summary>
    /// 权限配置都在这里。
    /// 给权限默认设置服务
    /// See <see cref="TbXiaoJuParamsPermissions" /> for all permission names. TbXiaoJuParams
    ///</summary>
    public class TbXiaoJuParamsAuthorizationProvider : AuthorizationProvider
    {
        private readonly bool _isMultiTenancyEnabled;

		public TbXiaoJuParamsAuthorizationProvider()
		{

		}

        public TbXiaoJuParamsAuthorizationProvider(bool isMultiTenancyEnabled)
        {
            _isMultiTenancyEnabled = isMultiTenancyEnabled;
        }

        public TbXiaoJuParamsAuthorizationProvider(IMultiTenancyConfig multiTenancyConfig)
        {
            _isMultiTenancyEnabled = multiTenancyConfig.IsEnabled;
        }

		public override void SetPermissions(IPermissionDefinitionContext context)
		{
			// 在这里配置了TbXiaoJuParams 的权限。
			var pages = context.GetPermissionOrNull(AppLtmPermissions.Pages) ?? context.CreatePermission(AppLtmPermissions.Pages, L("Pages"));


            var payparams = pages.Children.FirstOrDefault(p => p.Name == AppPermissions.Pages_BasicDataManage) ??
                            pages.CreateChildPermission(AppPermissions.Pages_BasicDataManage, L("BasicDataManage"));

            var administration = payparams.Children.FirstOrDefault(p => p.Name == AppPermissions.Pages_BasicDataManage_PayParams) ?? payparams.CreateChildPermission(AppPermissions.Pages_BasicDataManage_PayParams, L("Pay_Params"));

			var entityPermission = administration.CreateChildPermission(TbXiaoJuParamsPermissions.Node , L("TbXiaoJuParams"));
			entityPermission.CreateChildPermission(TbXiaoJuParamsPermissions.Query, L("QueryTbXiaoJuParams"));
			entityPermission.CreateChildPermission(TbXiaoJuParamsPermissions.Create, L("CreateTbXiaoJuParams"));
			entityPermission.CreateChildPermission(TbXiaoJuParamsPermissions.Edit, L("EditTbXiaoJuParams"));
			entityPermission.CreateChildPermission(TbXiaoJuParamsPermissions.Delete, L("DeleteTbXiaoJuParams"));
			entityPermission.CreateChildPermission(TbXiaoJuParamsPermissions.BatchDelete, L("BatchDeleteTbXiaoJuParams"));
			//entityPermission.CreateChildPermission(TbXiaoJuParamsPermissions.ExportExcel, L("ExportExcelTbXiaoJuParams"));


		}

		private static ILocalizableString L(string name)
		{
			return new LocalizableString(name, AppConsts.LocalizationSourceName);
		}
    }
}